package com.itheima.service.Impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.mapper.EmployeeMapper;
import com.itheima.pojo.Employee;
import com.itheima.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class EmployeeServiceImpl implements EmployeeService {
    @Autowired
    private EmployeeMapper employeeMapper;

    public Employee getEmployeeByUsernameAndPassword(String username, String password) {
        return employeeMapper.selectByUsernameAndPassword(username, password);
    }

    @Override
    public boolean addEmployee(Employee employee) {
        employee.setCreateTime(new Date(System.currentTimeMillis()));
        return employeeMapper.insert(employee) > 0;
    }

    @Override
    public Page<Employee> getPage(Integer page, Integer pageSize, String name) {
        Page<Employee> empPage = new Page<>(page,pageSize);
        return employeeMapper.selectPage(empPage, null);
    }


}
